﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using middleware.dominio;
using middleware.dominio.negocio;

namespace middleware
{
    public partial class VentanaLog : Form
    {
        private List<Log> logs;
        public VentanaLog()
        {
            InitializeComponent();
        }

        private void VentanaLog_Load(object sender, EventArgs e)
        {
            cargarDatos();
        }

        private void btnRefrescar_Click(object sender, EventArgs e)
        {
            cargarDatos();
        }

        private void Cerrar_Click(object sender, EventArgs e)
        {
            Dispose();
        }

        private void cargarDatos()
        {
            DateTime filtroFecha = new DateTime();
            this.logs = BusinessFactory.getMiddleware().ObtenerLogs(filtroFecha, "");       
            lstLogs.Items.Clear();
            foreach (Log auxLog in this.logs)
            {
                ListViewItem lviAAgregar = new ListViewItem(auxLog.fecha.ToString());
                lviAAgregar.SubItems.Add(auxLog.linea);
                if (auxLog.usuario != null)
                    lviAAgregar.SubItems.Add(auxLog.usuario.ToString());
                else
                    lviAAgregar.SubItems.Add("NoDefinido");

                lstLogs.Items.Add(lviAAgregar);
            }
        }
    }
}
